package main

import (
	"fmt"
	"net"
	"rpcdemo/pb"
	"rpcdemo/service"
	"rpcdemo/transport"

	"google.golang.org/grpc"
)

// 参考：https://junereycasuga.medium.com/go-grpc-with-go-kit-ff8c9151d2c1

func main() {
	svc := service.NewDemoService()
	gRPCServer := transport.NewGRPCServer(svc)

	trimSvc := service.NewTrimService()
	trimGRPCServer := transport.NewTrimGRPCServer(trimSvc)

	listener, err := net.Listen("tcp", ":9000")
	if err != nil {
		fmt.Println(1111, err)
		panic(err)
	}

	server := grpc.NewServer()
	pb.RegisterDemoServer(server, gRPCServer)
	pb.RegisterTrimSvcServer(server, trimGRPCServer)

	if err := server.Serve(listener); err != nil {
		fmt.Println(2222, err)
		panic(err)
	}
}
